// 装饰画数据模型
export class DecorationModel {
  constructor(data = {}) {
    this.id = data.id || null;
    this.userId = data.userId || null;
    this.styleId = data.styleId || null;
    this.roomId = data.roomId || null;
    this.imageUrl = data.imageUrl || '';
    this.roomImageUrl = data.roomImageUrl || '';
    this.createTime = data.createTime || new Date().toISOString();
    this.status = data.status || 0;
    this.tags = data.tags || [];
    this.keywords = data.keywords || [];
  }

  // 验证数据完整性
  validate() {
    return this.styleId && this.roomId;
  }

  // 转换为API请求数据格式
  toApiFormat() {
    return {
      style_id: this.styleId,
      room_id: this.roomId,
      tags: this.tags,
      keywords: this.keywords
    };
  }

  // 从API响应更新数据
  updateFromResponse(response) {
    this.id = response.id;
    this.imageUrl = response.image_url;
    this.roomImageUrl = response.room_image_url;
    this.createTime = response.create_time;
    this.status = response.status;
    return this;
  }
} 